import { $ } from './library/jquery-module.js';
import './library/jquery-extend-tabs.js';

$(function() {
    $('.login-way-fir').tabs({
        ev: 'click',
        active: 'active',
        show: 'show'
    });

    // 密码短信登录 扫码登录切换
    $('.scan-code').on('click', function() {
        $('.login-way-fir').css('display', 'none');
        $('.login-way-sec').css('display', 'block');
    });

    $('.phone-code').on('click', function() {
        $('.login-way-sec').css('display', 'none');
        $('.login-way-fir').css('display', 'block');
    });

    // 登录表单验证
    $('.login-subbtn>input').on('click', function() {
        let username = $('.username-input').val();
        let password = $('.password-in').val();
        // console.log(username);
        // console.log(password);
        $.ajax({
            type: "post",
            url: "../../interface/login.php",
            data: { "username": username, "password": password },
            dataType: "text",
            success: function(res) {
                console.log(res)
                if (res == 1) {
                    console.log(res);
                    $(window).attr('location', '../html/index.html');
                } else if (res == 0) {
                    console.log(res);
                    $(".wrong-msg").css("display", "block");
                }
            },
            error: function(res) {
                console.log(res.responseText);
            }
        });

    });

});